home *** CD-ROM | disk | FTP | other *** search
/ Aminet 50 / Aminet 50 (2002)(GTI - Schatztruhe)[!][Aug 2002].iso / Aminet / dev / mui / MCC_SpeedBar.lha / MCC_SpeedBar / Developer / C / Examples / demo2.c < prev    next >
C/C++ Source or Header  |  2002-06-13  |  6KB  |  156 lines

  1.  
  2. #include <proto/exec.h>
  3. #include <proto/dos.h>
  4. #include <proto/muimaster.h>
  5. #include <clib/alib_protos.h>
  6. #include <mui/SpeedBar_mcc.h>
  7. #include <mui/SpeedBarCfg_mcc.h>
  8. #include <string.h>
  9. #include <stdio.h>
  10.  
  11. /***********************************************************************/
  12.  
  13. long __stack = 8192;
  14. struct Library *MUIMasterBase;
  15.  
  16. /***********************************************************************/
  17.  
  18. #ifndef MAKE_ID
  19. #define MAKE_ID(a,b,c,d) ((ULONG) (a)<<24 | (ULONG) (b)<<16 | (ULONG) (c)<<8 | (ULONG) (d))
  20. #endif
  21.  
  22. /***********************************************************************/
  23.  
  24. struct MUIS_SpeedBar_Button buttons[] =
  25. {
  26.     {0, "_Get", "Get the disc.", 0, NULL},
  27.     {1, "Sa_ve", "Save the disc.", 0, NULL},
  28.     {2, "_Stop", "Stop the connection.", 0, NULL},
  29.     {MUIV_SpeedBar_Spacer},
  30.     {3, "_Disc", "Disc page.", 0, NULL},
  31.     {4, "_Matches", "Matches page.", 0, NULL},
  32.     {5, "_Edit", "Edit page.", 0, NULL},
  33.     {MUIV_SpeedBar_End},
  34. };
  35.  
  36. /***********************************************************************/
  37.  
  38. #define TEMPLATE "STRIP,NUMBUTTON/N"
  39.  
  40. int
  41. main(int argc,char **argv)
  42. {
  43.     struct RDArgs   *ra;
  44.     LONG            arg[2] = {0};
  45.     int             res;
  46.  
  47.     if (ra = ReadArgs(TEMPLATE,arg,NULL))
  48.     {
  49.         if (MUIMasterBase = OpenLibrary("muimaster.library",19))
  50.         {
  51.             Object                          *app, *win, *sb;
  52.             Object                          *cfg, *update;
  53.             struct MUIS_SpeedBarCfg_Config  c = {MUIV_SpeedBar_ViewMode_TextGfx,MUIV_SpeedBarCfg_Borderless|MUIV_SpeedBarCfg_Sunny};
  54.  
  55.             if (app = ApplicationObject,
  56.                     MUIA_Application_Title,         "SpeedBar Demo2",
  57.                     MUIA_Application_Version,       "$VER: SpeedBarDemo2 14.4 (13.6.2002)",
  58.                     MUIA_Application_Copyright,     "Copyright 1999-2002 by Alfonso Ranieri",
  59.                     MUIA_Application_Author,        "Alfonso Ranieri <alforan@tin.it>",
  60.                     MUIA_Application_Description,   "Speed(Bar|Button|BarCfg).mcc test",
  61.                     MUIA_Application_Base,          "SPEEDBARTEST",
  62.                     SubWindow, win = WindowObject,
  63.                         MUIA_Window_ID,             MAKE_ID('M','A','I','N'),
  64.                         MUIA_Window_Title,          "SpeedBar Demo2",
  65.                         WindowContents, VGroup,
  66.                             Child, HGroup,
  67.                                 GroupFrame,
  68.                                 Child, sb = SpeedBarObject,
  69.                                     MUIA_Group_Horiz,               TRUE,
  70.                                     MUIA_SpeedBar_Borderless,       TRUE,
  71.                                     MUIA_SpeedBar_Sunny,            TRUE,
  72.                                     MUIA_SpeedBar_Buttons,          buttons,
  73.                                     MUIA_SpeedBar_StripUnderscore,  TRUE,
  74.                                     MUIA_SpeedBar_EnableUnderscore, TRUE,
  75.                                     MUIA_SpeedBar_BarSpacer,        TRUE,
  76.                                     MUIA_SpeedBar_PicsDrawer,       "PROGDIR:Pics",
  77.                                     MUIA_SpeedBar_Strip,            arg[0] ? (char *)arg[0] : "Main.toolbar",
  78.                                     MUIA_SpeedBar_StripButtons,     arg[1] ? (*((ULONG *)arg[1])) : 14,
  79.                                 End,
  80.                                 Child, HSpace(0),
  81.                             End,
  82.                             Child, VSpace(0),
  83.                             Child, VGroup,
  84.                                 GroupFrameT("Appareance"),
  85.                                 Child, cfg = SpeedBarCfgObject,
  86.                                     MUIA_SpeedBarCfg_Config, &c,
  87.                                 End,
  88.                                 Child, VSpace(0),
  89.                                 Child, update = MUI_MakeObject(MUIO_Button,"_Update"),
  90.                             End,
  91.                             Child, VSpace(0),
  92.                         End,
  93.                     End,
  94.                 End)
  95.             {
  96.                 ULONG sigs = 0, id;
  97.  
  98.                 DoMethod(win,MUIM_Notify,MUIA_Window_CloseRequest,TRUE,MUIV_Notify_Application,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit);
  99.                 DoMethod(update,MUIM_Notify,MUIA_Pressed,FALSE,app,2,MUIM_Application_ReturnID,TAG_USER);
  100.  
  101.                 set(win,MUIA_Window_Open,TRUE);
  102.  
  103.                 while ((id = DoMethod(app,MUIM_Application_NewInput,&sigs))!=MUIV_Application_ReturnID_Quit)
  104.                 {
  105.                     if (id==TAG_USER)
  106.                     {
  107.                         struct MUIS_SpeedBarCfg_Config *c;
  108.  
  109.                         get(cfg,MUIA_SpeedBarCfg_Config,&c);
  110.  
  111.                         SetAttrs(sb,MUIA_SpeedBar_ViewMode,c->ViewMode,
  112.                                     MUIA_SpeedBar_Borderless,c->Flags & MUIV_SpeedBarCfg_Borderless,
  113.                                     MUIA_SpeedBar_RaisingFrame,c->Flags & MUIV_SpeedBarCfg_Raising,
  114.                                     MUIA_SpeedBar_SmallImages,c->Flags & MUIV_SpeedBarCfg_SmallButtons,
  115.                                     MUIA_SpeedBar_Sunny,c->Flags & MUIV_SpeedBarCfg_Sunny,
  116.                                     TAG_DONE);
  117.                     }
  118.  
  119.                     if (sigs)
  120.                     {
  121.                         sigs = Wait(sigs | SIGBREAKF_CTRL_C);
  122.                         if (sigs & SIGBREAKF_CTRL_C) break;
  123.                     }
  124.                 }
  125.  
  126.                 MUI_DisposeObject(app);
  127.  
  128.                 res = RETURN_OK;
  129.             }
  130.             else
  131.             {
  132.                 printf("%s: can't create application\n",argv[0]);
  133.                 res = RETURN_FAIL;
  134.             }
  135.  
  136.             CloseLibrary(MUIMasterBase);
  137.         }
  138.         else
  139.         {
  140.             printf("%s: Can't open muimaster.library ver 19 or higher\n",argv[0]);
  141.             res = RETURN_ERROR;
  142.         }
  143.  
  144.         FreeArgs(ra);
  145.     }
  146.     else
  147.     {
  148.         PrintFault(IoErr(),argv[0]);
  149.         res = RETURN_FAIL;
  150.     }
  151.  
  152.     return res;
  153. }
  154.  
  155. /***********************************************************************/
  156.